package dao

import (
	"log"

	"gitee.com/Yu-eng/Myproject/my-go-blog/models"
)

func GetUserNameById(userId int) string {

	row, err := DB.Query("select user_name from blog_user where uid = ?", userId)
	if err != nil {
		log.Println(err)
	}

	var userName string
	//要对row 的结果先进行next 操作才能得到第一行的结果
	row.Next()
	err = row.Scan(&userName)
	if err != nil {
		log.Println("getcategorynamebyid row.scan error ", err)
	}

	return userName
}

func GetUser(userName, passwd string) models.User {
	row := DB.QueryRow("select user_name from blog_user where user_name = ? and passwd = ? limit 1", userId)
	if err != nil {
		log.Println(err)
	}
}
